﻿using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;

namespace Model.Entity
{
    public partial class DBContext : DbContext
    {
        public DBContext()
        {
        }

        public DBContext(DbContextOptions<DBContext> options)
            : base(options)
        {
        }

        public virtual DbSet<ChatMessage> ChatMessage { get; set; }
        public virtual DbSet<EfmigrationsHistory> EfmigrationsHistory { get; set; }
        public virtual DbSet<Friends> Friends { get; set; }
        public virtual DbSet<NoticeMessage> NoticeMessage { get; set; }
        public virtual DbSet<SocialMessage> SocialMessage { get; set; }
        public virtual DbSet<User> User { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder.UseMySql("Server=101.37.175.132;Database=chat;Uid=zhangdashuai;Pwd=ow9eOhg6Z4IYe$Fm;");
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<ChatMessage>(entity =>
            {
                entity.ToTable("chat_message");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.ChatRoomId)
                    .HasColumnName("chat_room_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.Content)
                    .IsRequired()
                    .HasColumnName("content")
                    .HasColumnType("varchar(500)");

                entity.Property(e => e.ContentType)
                    .HasColumnName("content_type")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.IsRead)
                    .HasColumnName("is_read")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.IsReceiver)
                    .HasColumnName("is_receiver")
                    .HasColumnType("int(11)");

                entity.Property(e => e.MessageId)
                    .IsRequired()
                    .HasColumnName("message_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.MessageType)
                    .HasColumnName("message_type")
                    .HasColumnType("int(11)");

                entity.Property(e => e.ReadTime)
                    .HasColumnName("read_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.ReceiverId)
                    .IsRequired()
                    .HasColumnName("receiver_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.ReceiverStatus)
                    .HasColumnName("receiver_status")
                    .HasColumnType("int(11)");

                entity.Property(e => e.ReceiverTime)
                    .HasColumnName("receiver_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.SenderId)
                    .IsRequired()
                    .HasColumnName("sender_id")
                    .HasColumnType("varchar(50)");
            });

            modelBuilder.Entity<EfmigrationsHistory>(entity =>
            {
                entity.HasKey(e => e.MigrationId)
                    .HasName("PRIMARY");

                entity.ToTable("__EFMigrationsHistory");

                entity.Property(e => e.MigrationId).HasColumnType("varchar(95)");

                entity.Property(e => e.ProductVersion)
                    .IsRequired()
                    .HasColumnType("varchar(32)");
            });

            modelBuilder.Entity<Friends>(entity =>
            {
                entity.ToTable("friends");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.DisableTime)
                    .HasColumnName("disable_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.Disabled)
                    .HasColumnName("disabled")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.FriendId)
                    .IsRequired()
                    .HasColumnName("friend_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.FriendMemberId)
                    .IsRequired()
                    .HasColumnName("friend_member_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.FriendRelationId)
                    .IsRequired()
                    .HasColumnName("friend_relation_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.FriendRemark)
                    .HasColumnName("friend_remark")
                    .HasColumnType("varchar(20)");

                entity.Property(e => e.GroupId)
                    .HasColumnName("group_id")
                    .HasColumnType("varchar(10)");

                entity.Property(e => e.MemberId)
                    .IsRequired()
                    .HasColumnName("member_id")
                    .HasColumnType("varchar(50)");
            });

            modelBuilder.Entity<NoticeMessage>(entity =>
            {
                entity.ToTable("notice_message");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.Extend)
                    .HasColumnName("extend")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.FromMemberId)
                    .IsRequired()
                    .HasColumnName("from_member_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.IsRead)
                    .HasColumnName("is_read")
                    .HasColumnType("int(11)");

                entity.Property(e => e.MessageType)
                    .HasColumnName("message_type")
                    .HasColumnType("int(11)");

                entity.Property(e => e.ReadTime)
                    .HasColumnName("read_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.ToMemberId)
                    .IsRequired()
                    .HasColumnName("to_member_id")
                    .HasColumnType("varchar(50)");
            });

            modelBuilder.Entity<SocialMessage>(entity =>
            {
                entity.ToTable("social_message");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.Extend)
                    .HasColumnName("extend")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.FromMemberId)
                    .IsRequired()
                    .HasColumnName("from_member_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.HandleMessage)
                    .HasColumnName("handle_message")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.HandleResult)
                    .HasColumnName("handle_result")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.IsHandle)
                    .HasColumnName("is_handle")
                    .HasColumnType("int(11)")
                    .HasDefaultValueSql("'0'");

                entity.Property(e => e.IsRead)
                    .HasColumnName("is_read")
                    .HasColumnType("int(11)");

                entity.Property(e => e.MessageId)
                    .IsRequired()
                    .HasColumnName("message_id")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.MessageType)
                    .HasColumnName("message_type")
                    .HasColumnType("int(11)");

                entity.Property(e => e.ReadTime)
                    .HasColumnName("read_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.Rocial)
                    .HasColumnName("rocial")
                    .HasColumnType("int(11)");

                entity.Property(e => e.SendMessage)
                    .HasColumnName("send_message")
                    .HasColumnType("varchar(50)");

                entity.Property(e => e.ToMemberId)
                    .IsRequired()
                    .HasColumnName("to_member_id")
                    .HasColumnType("varchar(50)");
            });

            modelBuilder.Entity<User>(entity =>
            {
                entity.ToTable("user");

                entity.Property(e => e.Id)
                    .HasColumnName("id")
                    .HasColumnType("int(11)");

                entity.Property(e => e.Avatar)
                    .HasColumnName("avatar")
                    .HasColumnType("varchar(2080)");

                entity.Property(e => e.CreateTime)
                    .HasColumnName("create_time")
                    .HasColumnType("datetime");

                entity.Property(e => e.MemberId)
                    .IsRequired()
                    .HasColumnName("member_id")
                    .HasColumnType("varchar(30)");

                entity.Property(e => e.NickName)
                    .IsRequired()
                    .HasColumnName("nick_name")
                    .HasColumnType("varchar(8)");

                entity.Property(e => e.UserId)
                    .IsRequired()
                    .HasColumnName("user_id")
                    .HasColumnType("varchar(12)");

                entity.Property(e => e.UserPwd)
                    .IsRequired()
                    .HasColumnName("user_pwd")
                    .HasColumnType("varchar(16)");
            });
        }
    }
}
